package vectordb;

import java.util.HashMap;
import java.util.Map;

/**
 * 表示向量文档的类
 */
public class VectorDocument {
    private String id;
    private double[] vector;
    private String content;
    private String relativePath;
    private int startLine;
    private int endLine;
    private String fileExtension;
    private Map<String, Object> metadata;

    /**
     * 创建一个新的向量文档
     */
    public VectorDocument() {
        this.metadata = new HashMap<>();
    }

    /**
     * 创建一个新的向量文档
     * 
     * @param id 文档ID
     * @param vector 向量数据
     * @param content 文档内容
     * @param relativePath 相对路径
     * @param startLine 开始行
     * @param endLine 结束行
     * @param fileExtension 文件扩展名
     */
    public VectorDocument(String id, double[] vector, String content, String relativePath, 
                          int startLine, int endLine, String fileExtension) {
        this.id = id;
        this.vector = vector;
        this.content = content;
        this.relativePath = relativePath;
        this.startLine = startLine;
        this.endLine = endLine;
        this.fileExtension = fileExtension;
        this.metadata = new HashMap<>();
    }

    /**
     * 创建一个新的向量文档
     * 
     * @param id 文档ID
     * @param vector 向量数据
     * @param content 文档内容
     * @param relativePath 相对路径
     * @param startLine 开始行
     * @param endLine 结束行
     * @param fileExtension 文件扩展名
     * @param metadata 元数据
     */
    public VectorDocument(String id, double[] vector, String content, String relativePath, 
                          int startLine, int endLine, String fileExtension, Map<String, Object> metadata) {
        this.id = id;
        this.vector = vector;
        this.content = content;
        this.relativePath = relativePath;
        this.startLine = startLine;
        this.endLine = endLine;
        this.fileExtension = fileExtension;
        this.metadata = metadata != null ? metadata : new HashMap<>();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public double[] getVector() {
        return vector;
    }

    public void setVector(double[] vector) {
        this.vector = vector;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getRelativePath() {
        return relativePath;
    }

    public void setRelativePath(String relativePath) {
        this.relativePath = relativePath;
    }

    public int getStartLine() {
        return startLine;
    }

    public void setStartLine(int startLine) {
        this.startLine = startLine;
    }

    public int getEndLine() {
        return endLine;
    }

    public void setEndLine(int endLine) {
        this.endLine = endLine;
    }

    public String getFileExtension() {
        return fileExtension;
    }

    public void setFileExtension(String fileExtension) {
        this.fileExtension = fileExtension;
    }

    public Map<String, Object> getMetadata() {
        return metadata;
    }

    public void setMetadata(Map<String, Object> metadata) {
        this.metadata = metadata;
    }

    public void addMetadata(String key, Object value) {
        this.metadata.put(key, value);
    }

    public Object getMetadataValue(String key) {
        return this.metadata.get(key);
    }
}